package com.lb.view;

import com.lb.kugou.MainActivity;
import com.lb.kugou.R;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class LocalFragment extends Fragment {

	private View viewGroup;
	private ImageButton ibnMainListTopLeft;
	private MainActivity mainActivity;
	private ImageButtonInc ibiAllPlay;
	private ImageButtonInc ibiChoose;
	private ImageButtonInc ibiSearch;
	private LinearLayout lltChooseMid;
	private LinearLayout lltSearchMid;
	private LinearLayout lltDefultMid;
	private ImageButtonInc ibiChooseAll;
	private ImageButtonInc ibiChooseCancel;
	private Button btnSearchCancel;
	private ListView lvwLocalFragment;
	private TextView tvwMainListTopMid;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		mainActivity = (MainActivity) activity;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		viewGroup = inflater.inflate(R.layout.local_fragment, container);
		ini();
		return viewGroup;
	}

	private void ini() {
		ibnMainListTopLeft = (ImageButton) viewGroup.findViewById(R.id.ibnMainListTopLeft); 
		ibnMainListTopLeft.setOnClickListener(onClickListener);
		tvwMainListTopMid = (TextView)viewGroup.findViewById(R.id.tvwMainListTopMid);
		tvwMainListTopMid.setText(String.format(getString(R.string.localMusicText), 1));
		
		ibiAllPlay = (ImageButtonInc) viewGroup.findViewById(R.id.ibiAllPlay);
		ibiAllPlay.setOnClickListener(onClickListener);
		ibiSearch = (ImageButtonInc) viewGroup.findViewById(R.id.ibiSearch);
		ibiSearch.setOnClickListener(onClickListener);
		ibiChoose = (ImageButtonInc) viewGroup.findViewById(R.id.ibiChoose);
		ibiChoose.setOnClickListener(onClickListener);
		ibiChooseAll = (ImageButtonInc) viewGroup.findViewById(R.id.ibiChooseAll);
		ibiChooseAll.setOnClickListener(onClickListener);
		ibiChooseCancel = (ImageButtonInc) viewGroup.findViewById(R.id.ibiChooseCancel);
		ibiChooseCancel.setOnClickListener(onClickListener);
		btnSearchCancel = (Button) viewGroup.findViewById(R.id.btnSearchCancel);
		btnSearchCancel.setOnClickListener(onClickListener);
		lltChooseMid = (LinearLayout) viewGroup.findViewById(R.id.lltChooseMid);
		lltSearchMid = (LinearLayout) viewGroup.findViewById(R.id.lltSearchMid);
		lltDefultMid = (LinearLayout) viewGroup.findViewById(R.id.lltDefultMid);
		lvwLocalFragment = (ListView) viewGroup.findViewById(R.id.lvwLocalFragment);
		
		
		
	}

	private OnClickListener onClickListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.ibnMainListTopLeft:
				mainActivity.mainContent.setCurrentSeat(0);
				break;
			case R.id.ibiChoose:
				lltDefultMid.setVisibility(ViewGroup.GONE);
				lltSearchMid.setVisibility(ViewGroup.GONE);
				lltChooseMid.setVisibility(ViewGroup.VISIBLE);
				break;
			case R.id.ibiSearch:
				lltDefultMid.setVisibility(ViewGroup.GONE);
				lltSearchMid.setVisibility(ViewGroup.VISIBLE);
				lltChooseMid.setVisibility(ViewGroup.GONE);
				break;
			case R.id.ibiChooseCancel:
				lltDefultMid.setVisibility(ViewGroup.VISIBLE);
				lltSearchMid.setVisibility(ViewGroup.GONE);
				lltChooseMid.setVisibility(ViewGroup.GONE);
				break;
			case R.id.btnSearchCancel:
				lltDefultMid.setVisibility(ViewGroup.VISIBLE);
				lltSearchMid.setVisibility(ViewGroup.GONE);
				lltChooseMid.setVisibility(ViewGroup.GONE);
				break;
			}
		}
	};

}
